From e6fa5aeb4f807fb3d5f3b025faced65ede4140dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 20 May 2012 12:47:20 +0000 Subject: [PATCH] Added stripTags (default: false) to allow stripping out HTML tags --- .../interfaces/debug/class_Debugger.php | 5 +++-- .../io/output/class_OutputStreamer.php | 4 +++- .../main/class_BaseFrameworkSystem.php | 5 +++-- .../main/debug/class_DebugConsoleOutput.php | 21 +++++++++++++------ .../main/debug/class_DebugErrorLogOutput.php | 9 +++++--- .../main/debug/class_DebugWebOutput.php | 13 +++++++----- .../main/output/class_ConsoleOutput.php | 3 ++- inc/classes/main/output/class_WebOutput.php | 4 +++- .../debug/class_DebugMiddleware.php | 5 +++-- 9 files changed, 46 insertions(+), 23 deletions(-) diff --git a/inc/classes/interfaces/debug/class_Debugger.php b/inc/classes/interfaces/debug/class_Debugger.php index 0520e552..5fd54f37 100644 --- a/inc/classes/interfaces/debug/class_Debugger.php +++ b/inc/classes/interfaces/debug/class_Debugger.php @@ -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] diff --git a/inc/classes/interfaces/io/output/class_OutputStreamer.php b/inc/classes/interfaces/io/output/class_OutputStreamer.php index 57ddaaf0..b3416573 100644 --- a/inc/classes/interfaces/io/output/class_OutputStreamer.php +++ b/inc/classes/interfaces/io/output/class_OutputStreamer.php @@ -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] diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 4b2812dc..df2e5a2f 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -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; diff --git a/inc/classes/main/debug/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php index 2c06c1f7..16e8dfa8 100644 --- a/inc/classes/main/debug/class_DebugConsoleOutput.php +++ b/inc/classes/main/debug/class_DebugConsoleOutput.php @@ -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 } diff --git a/inc/classes/main/debug/class_DebugErrorLogOutput.php b/inc/classes/main/debug/class_DebugErrorLogOutput.php index 49ab734b..22fe5598 100644 --- a/inc/classes/main/debug/class_DebugErrorLogOutput.php +++ b/inc/classes/main/debug/class_DebugErrorLogOutput.php @@ -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); diff --git a/inc/classes/main/debug/class_DebugWebOutput.php b/inc/classes/main/debug/class_DebugWebOutput.php index 7ec70036..2d931db4 100644 --- a/inc/classes/main/debug/class_DebugWebOutput.php +++ b/inc/classes/main/debug/class_DebugWebOutput.php @@ -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
$output = str_replace("
", '', $output); print(stripslashes($output)."
\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 } /** diff --git a/inc/classes/main/output/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php index 9545ef06..5df93cba 100644 --- a/inc/classes/main/output/class_ConsoleOutput.php +++ b/inc/classes/main/output/class_ConsoleOutput.php @@ -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); } } diff --git a/inc/classes/main/output/class_WebOutput.php b/inc/classes/main/output/class_WebOutput.php index 9b1223c6..92110f09 100644 --- a/inc/classes/main/output/class_WebOutput.php +++ b/inc/classes/main/output/class_WebOutput.php @@ -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)); } } diff --git a/inc/classes/middleware/debug/class_DebugMiddleware.php b/inc/classes/middleware/debug/class_DebugMiddleware.php index c5f49f5e..811ca5f6 100644 --- a/inc/classes/middleware/debug/class_DebugMiddleware.php +++ b/inc/classes/middleware/debug/class_DebugMiddleware.php @@ -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); } } -- 2.39.5