aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes/class.pagelet.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2015-04-15 21:29:19 +0200
committerThomas Lange <code@nerdmind.de>2015-04-15 21:29:19 +0200
commitbf996f7247133c536511c23b6ad30aa222bfd6d9 (patch)
tree1d9388e6331454fbc9b68b5006a64c4563c202cd /include/classes/class.pagelet.php
downloadbigpipe-bf996f7247133c536511c23b6ad30aa222bfd6d9.tar.gz
bigpipe-bf996f7247133c536511c23b6ad30aa222bfd6d9.tar.xz
bigpipe-bf996f7247133c536511c23b6ad30aa222bfd6d9.zip
Initial commit
Diffstat (limited to 'include/classes/class.pagelet.php')
-rwxr-xr-xinclude/classes/class.pagelet.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/include/classes/class.pagelet.php b/include/classes/class.pagelet.php
new file mode 100755
index 0000000..c1f211a
--- /dev/null
+++ b/include/classes/class.pagelet.php
@@ -0,0 +1,84 @@
+<?php
+class Pagelet {
+ private $ID = NULL;
+ private $HTML = NULL;
+ private $JSCode = "";
+ private $CSSFiles = [];
+ private $JSFiles = [];
+ private static $count = 0;
+
+ public function __construct($priority = 50) {
+ $this->ID = 'P'.++self::$count;
+ BigPipe::addPagelet($this, $priority);
+ }
+
+ #====================================================================================================
+ # ID zurückgeben
+ #====================================================================================================
+ public function getID() {
+ return $this->ID;
+ }
+
+ #====================================================================================================
+ # HTML-Code zurückgeben
+ #====================================================================================================
+ public function getHTML() {
+ return $this->HTML;
+ }
+
+ #====================================================================================================
+ # CSS-Ressourcen zurückgeben
+ #====================================================================================================
+ public function getCSSFiles() {
+ return $this->CSSFiles;
+ }
+
+ #====================================================================================================
+ # JS-Ressourcen zurückgeben
+ #====================================================================================================
+ public function getJSFiles() {
+ return $this->JSFiles;
+ }
+
+ #====================================================================================================
+ # JS-Code zurückgeben
+ #====================================================================================================
+ public function getJSCode() {
+ return $this->JSCode;
+ }
+
+ #====================================================================================================
+ # HTML-Code hinzufügen
+ #====================================================================================================
+ public function addHTML($HTML) {
+ $this->HTML .= $HTML;
+ }
+
+ #====================================================================================================
+ # CSS-Ressource hinzufügen
+ #====================================================================================================
+ public function addCSS($file) {
+ $this->CSSFiles[] = $file;
+ }
+
+ #====================================================================================================
+ # JS-Ressource hinzufügen
+ #====================================================================================================
+ public function addJS($file) {
+ $this->JSFiles[] = $file;
+ }
+
+ #====================================================================================================
+ # JS-Code hinzufügen
+ #====================================================================================================
+ public function addJSCode($code) {
+ $this->JSCode .= $code;
+ }
+
+ #====================================================================================================
+ # Magische Methode: __toString()
+ #====================================================================================================
+ public function __toString() {
+ return '<div id="'.$this->getID().'">'.((!BigPipe::isEnabled()) ? $this->getHTML() : NULL).'</div>';
+ }
+} \ No newline at end of file