aboutsummaryrefslogtreecommitdiffstats
path: root/include/pagelets.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2018-01-16 17:03:22 +0100
committerThomas Lange <code@nerdmind.de>2018-01-16 17:03:22 +0100
commit7c02cc7dee9d3b0440c4ccabc18762e8b87d1e24 (patch)
tree61764782518992a5c298c458cbadbea013b9730a /include/pagelets.php
parentb20d9dcac191fadc671da69f0a82ab7065554ca6 (diff)
downloadbigpipe-7c02cc7dee9d3b0440c4ccabc18762e8b87d1e24.tar.gz
bigpipe-7c02cc7dee9d3b0440c4ccabc18762e8b87d1e24.tar.xz
bigpipe-7c02cc7dee9d3b0440c4ccabc18762e8b87d1e24.zip
Use seperate classes for debugging
The debug mechanism has been changed. Instead of keeping the debug mechanism hardcoded within the core classes, it's now possible and recommended to use the seperate debugging classes which you can modify like you want. Those classes inherit their associated core classes and can add some debugging stuff. This has the advantage of having a clean core code without any debugging stuff. If the debug classes are not used then they shall not be included and their code will not be initialized.
Diffstat (limited to 'include/pagelets.php')
-rw-r--r--include/pagelets.php29
1 files changed, 18 insertions, 11 deletions
diff --git a/include/pagelets.php b/include/pagelets.php
index cdb1a14..43d1992 100644
--- a/include/pagelets.php
+++ b/include/pagelets.php
@@ -2,30 +2,37 @@
#===============================================================================
# Enable debugging mode
#===============================================================================
-BigPipe\BigPipe::debugging(TRUE);
+$DEBUGGING = TRUE;
+
+#===============================================================================
+# Namespace paths based on whether the debugging mode is enabled
+#===============================================================================
+$pagelet = ($DEBUGGING ? 'Debugging' : 'BigPipe').'\Pagelet';
+$stylesheet = ($DEBUGGING ? 'Debugging' : 'BigPipe').'\Resource\Stylesheet';
+$javascript = ($DEBUGGING ? 'Debugging' : 'BigPipe').'\Resource\Javascript';
#===============================================================================
# Pagelet with red background color
#===============================================================================
-$PageletRed = new BigPipe\Pagelet('redPL');
+$PageletRed = new $pagelet('redPL');
$PageletRed->addHTML('<section id="red" class="text">I AM A PAGELET WITH RED BACKGROUND</section>');
-$PageletRed->addResource(new BigPipe\Resource\Stylesheet(NULL, 'static/red.php'));
-$PageletRed->addResource(new BigPipe\Resource\Javascript(NULL, 'static/delayJS.php'));
+$PageletRed->addResource(new $stylesheet(NULL, 'static/red.php'));
+$PageletRed->addResource(new $javascript(NULL, 'static/delayJS.php'));
$PageletRed->addJSCode("document.getElementById('red').innerHTML += ' [JS executed]';document.getElementById('red').style.borderRadius = '30px';");
#===============================================================================
# Pagelet with blue background color
#===============================================================================
-$PageletBlue = new BigPipe\Pagelet('bluePL', BigPipe\Pagelet::PRIORITY_HIGH);
+$PageletBlue = new $pagelet('bluePL', BigPipe\Pagelet::PRIORITY_HIGH);
$PageletBlue->addHTML('<section id="blue" class="text">I AM A PAGELET WITH BLUE BACKGROUND</section>');
-$PageletBlue->addResource(new BigPipe\Resource\Stylesheet(NULL, 'static/blue.php'));
-$PageletBlue->addResource(new BigPipe\Resource\Javascript(NULL, 'static/delayJS.php'));
+$PageletBlue->addResource(new $stylesheet(NULL, 'static/blue.php'));
+$PageletBlue->addResource(new $javascript(NULL, 'static/delayJS.php'));
$PageletBlue->addJSCode("document.getElementById('blue').innerHTML += ' [JS executed]';document.getElementById('blue').style.borderRadius = '30px';");
#===============================================================================
# Pagelet with green background color
#===============================================================================
-$PageletGreen = new BigPipe\Pagelet('greenPL');
+$PageletGreen = new $pagelet('greenPL');
{
#===============================================================================
@@ -42,7 +49,7 @@ $PageletGreen = new BigPipe\Pagelet('greenPL');
// the first which arrives, but it will first be displayed if his dependency
// pagelets are already displayed.
- $InnerPagelet = new BigPipe\Pagelet('innerPL', BigPipe\Pagelet::PRIORITY_HIGHEST);
+ $InnerPagelet = new $pagelet('innerPL', BigPipe\Pagelet::PRIORITY_HIGHEST);
// NOTICE: You can also use the Pagelet ID (as string) as argument. May be helpful
// if a dependency Pagelet object is not accessible within the current scope.
@@ -52,7 +59,7 @@ $PageletGreen = new BigPipe\Pagelet('greenPL');
}
$PageletGreen->addHTML('<section id="green" class="text">I AM A PAGELET WITH GREEN BACKGROUND'.$InnerPagelet.'</section>');
-$PageletGreen->addResource(new BigPipe\Resource\Stylesheet(NULL, 'static/green.php'));
-$PageletGreen->addResource(new BigPipe\Resource\Javascript(NULL, 'static/delayJS.php'));
+$PageletGreen->addResource(new $stylesheet(NULL, 'static/green.php'));
+$PageletGreen->addResource(new $javascript(NULL, 'static/delayJS.php'));
$PageletGreen->addJSCode("document.getElementById('green').innerHTML += ' [JS executed]';document.getElementById('green').style.borderRadius = '30px';");
?> \ No newline at end of file