Added stripTags (default: false) to allow stripping out HTML tags
authorRoland Häder <roland@mxchange.org>
Sun, 20 May 2012 12:47:20 +0000 (12:47 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 20 May 2012 12:47:20 +0000 (12:47 +0000)
inc/classes/interfaces/debug/class_Debugger.php
inc/classes/interfaces/io/output/class_OutputStreamer.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/debug/class_DebugConsoleOutput.php
inc/classes/main/debug/class_DebugErrorLogOutput.php
inc/classes/main/debug/class_DebugWebOutput.php
inc/classes/main/output/class_ConsoleOutput.php
inc/classes/main/output/class_WebOutput.php
inc/classes/middleware/debug/class_DebugMiddleware.php

index 0520e552165937118231ffd856a43f150e229337..5fd54f370f846a9bf1da7a9d60861e6096641c34 100644 (file)
@@ -25,10 +25,11 @@ interface Debugger extends FrameworkInterface {
        /**
         * Outputs the given data
         *
-        * @param               $output Debug text for output
+        * @param       $output         Debug text for output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       function outputStream ($output);
+       function outputStream ($output, $stripTags = false);
 }
 
 // [EOF]
index 57ddaaf0de67da137730b154d6a637a4d70acb97..b34165737bcab729ef479a8c1a751bfbc8e6750c 100644 (file)
@@ -25,9 +25,11 @@ interface OutputStreamer extends Streamable {
        /**
         * Output the code
         *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       function output ($outStream = false);
+       function output ($outStream = false, $stripTags = false);
 }
 
 // [EOF]
index 4b2812dc41adfc530e6fbbb9fe106b0d69f71dc4..df2e5a2f880c99ad0c24b9ad5c87d5ca2ff5c9b6 100644 (file)
@@ -1396,10 +1396,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * Outputs a debug message whether to debug instance (should be set!) or dies with or pints the message
         *
         * @param       $message        Message we shall send out...
-        * @param       $doPrint        Whether we shall print or die here which first is the default
+        * @param       $doPrint        Whether print or die here (default: print)
+        * @paran       $stripTags      Whether to strip tags (default: false)
         * @return      void
         */
-       public function debugOutput ($message, $doPrint = true) {
+       public function debugOutput ($message, $doPrint = true, $stripTags = false) {
                // Set debug instance to NULL
                $debugInstance = NULL;
 
index 2c06c1f7ecc81f1733d6ee4e55865c28100b204e..16e8dfa80435ad8ec351be442f000f655b5d5706 100644 (file)
@@ -49,16 +49,23 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output
         * Outputs the given data without HTML tags
         *
         * @param       $output         The HTML'ed output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function outputStream ($output) {
-               // Prepare the output
-               $output = trim(html_entity_decode(strip_tags(stripslashes($output))));
+       public final function outputStream ($output, $stripTags = false) {
+               // Strip HTML tags out?
+               if ($stripTags === true) {
+                       // Prepare the output without HTML tags
+                       $output = trim(html_entity_decode(strip_tags(stripslashes($output))));
+               } else {
+                       // Prepare the output with HTML tags
+                       $output = trim(stripslashes($output));
+               }
 
                // Are debug times enabled?
                if ($this->getConfigInstance()->getConfigEntry('debug_output_timings') == 'Y') {
                        // Output it first
-                       print($this->getPrintableExecutionTime());
+                       $output = $this->getPrintableExecutionTime() . $output;
                } // END - if
 
                // And print it out...
@@ -68,12 +75,14 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output
        /**
         * Output the code
         *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function output ($outStream = false) {
+       public final function output ($outStream = false, $stripTags = false) {
                // Empty output will be silently ignored
                if ($outStream !== false) {
-                       $this->outputStream($outStream);
+                       $this->outputStream($outStream, $stripTags);
                } // END - if
        }
 
index 49ab734bf6f21f5454662d93a4b5880a96cb04bd..22fe5598f367ccf81e1f1bfd8f2b26d1c83f6670 100644 (file)
@@ -46,12 +46,13 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu
        }
 
        /**
-        * Outputs the given data without HTML tags
+        * Outputs the given data without HTML tags, ignores $stripTags
         *
         * @param       $output         The HTML'ed output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function outputStream ($output) {
+       public final function outputStream ($output, $stripTags = false) {
                // Split multiple lines into and array to put them out line-by-line
                $errorLines = explode(chr(10), $output);
 
@@ -71,9 +72,11 @@ class DebugErrorLogOutput extends BaseFrameworkSystem implements Debugger, Outpu
        /**
         * Output the code
         *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function output ($outStream = false) {
+       public final function output ($outStream = false, $stripTags = false) {
                // Empty output will be silently ignored
                if ($outStream !== false) {
                        $this->outputStream($outStream);
index 7ec70036f2cbb2a5c9abff9a990d8e81f49ec690..2d931db4da476a042dcda8408a6591f4f94de57e 100644 (file)
@@ -46,12 +46,13 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre
        }
 
        /**
-        * Outputs the given data directly
+        * Outputs the given data directly, ignores $stripTags
         *
         * @param       $output         The HTML output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function outputStream ($output) {
+       public final function outputStream ($output, $stripTags = false) {
                // Strip out <br />
                $output = str_replace("<br />", '', $output);
                print(stripslashes($output)."<br />\n");
@@ -60,13 +61,15 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre
        /**
         * Output the code
         *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function output ($outStream = false) {
+       public final function output ($outStream = false, $stripTags = false) {
                // Empty output will be silently ignored
                if ($outStream !== false) {
-                       $this->outputStream($outStream);
-               }
+                       $this->outputStream($outStream, $stripTags);
+               } // END - if
        }
 
        /**
index 9545ef06a66a3a74dde7a6316b4425026ee15922..5df93cba746504da9f99c018c21fe567a89bd319 100644 (file)
@@ -84,9 +84,10 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer {
         * Output the code
         *
         * @param       $outStream      Something we shall sent to the console
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function output ($outStream = false) {
+       public final function output ($outStream = false, $stripTags = false) {
                print trim($outStream) . chr(10);
        }
 }
index 9b1223c675d9ace13af24c0ad19cca944469a86c..92110f09bc3c35191351d5e1b24103f64960111a 100644 (file)
@@ -67,9 +67,11 @@ class WebOutput extends BaseFrameworkSystem implements OutputStreamer, Registera
        /**
         * Output the code
         *
+        * @param       $outStream      Stream to output
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function output ($outStream = false) {
+       public final function output ($outStream = false, $stripTags = false) {
                print(stripslashes($outStream));
        }
 }
index c5f49f5eb0721f45191de4230575f35ef438fcf1..811ca5f66c4ee6e3d1b218a13168f4e40207e1a7 100644 (file)
@@ -104,9 +104,10 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
         * output instance.
         *
         * @param       $outStream      Data we shall 'stream' out to the world
+        * @param       $stripTags      Whether HTML tags shall be stripped out
         * @return      void
         */
-       public final function output ($outStream) {
+       public final function output ($outStream, $stripTags = false) {
                // Is the output stream set
                if (empty($outStream)) {
                        // @TODO Initialization phase
@@ -114,7 +115,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
                } // END - if
 
                // Use the output instance
-               $this->outputInstance->outputStream($outStream);
+               $this->outputInstance->outputStream($outStream, $stripTags);
        }
 }