outputType = self::NO_OUTPUT; } public static function setOutputType($outputType) { $singleton = self::getSingelton(); switch ($outputType) { case self::INLINE_PRE_OUTPUT: case self::INLINE_COMMENT_OUTPUT: case self::DEFERRED_OUTPUT: case self::NO_OUTPUT: return $singleton->_setOutputType($outputType); break; default: return $singleton->_setOutputType(self::NO_OUTPUT); } } protected function _setOutputType($outputType) { $this->outputType = $outputType; } public static function output($d, $label="*debug* ", $exitHere = false) { $singleton = self::getSingelton(); return $singleton->_output($d, $label, $exitHere); } protected function _output($d, $label, $exitHere) { if ($this->outputType != self::NO_OUTPUT ) { if ($this->outputType == self::DEFERRED_OUTPUT) { if (!isset($this->deferredOutput) || !is_array($this->deferredOutput)) $this->deferredOutput = array(); $this->deferredOutput[] = array('label' => $label, 'value' => $d); } else { switch ($this->outputTyp) { case self::INLINE_PRE_OUTPUT : $__debugUtilLabelPrefix = "\n
\n";
						$__debugUtilLabelSuffix = ":\n\n";
						$__debugUtilDataPrefix = "";
						$__debugUtilDataSuffix = "\n
\n"; break; case self::INLINE_COMMENT_OUTPUT : default: $__debugUtilLabelPrefix = "\n\n"; break; } echo $__debugUtilLabelPrefix . $label . $__debugUtilLabelSuffix; echo $__debugUtilDataPrefix; print_r($d); echo $__debugUtilDataSuffix; } } if ($exitHere) { if ($this->outputType == self::DEFERRED_OUTPUT) { echo "

Exiting early; deferred debug output shown here:

\n"; echo $this->_getDeferredOutputAsPre(); } exit(); } } public function getDeferredOutput() { $singleton = self::getSingelton(); return $singleton->_getDeferredOutput(); } protected function _getDeferredOutput() { if ($this->outputType == self::DEFERRED_OUTPUT) { if (!isset($this->deferredOutput) || !is_array($this->deferredOutput)) $this->deferredOutput = array(); return $this->deferredOutput; } else return null; } public function getDeferredOutputAsPre() { $singleton = self::getSingelton(); return $singleton->_getDeferredOutputAsPre(); } protected function _getDeferredOutputAsPre() { if ($this->outputType == self::DEFERRED_OUTPUT) { if (!isset($this->deferredOutput) || !is_array($this->deferredOutput)) $this->deferredOutput = array(); $str = ""; foreach ($this->deferredOutput as $debugElement) { $label = $debugElement['label']; $d = $debugElement['value']; $__debugUtilLabelPrefix = "\n
\n";
				$__debugUtilLabelSuffix = ":\n\n";
				$__debugUtilDataPrefix = "";
				$__debugUtilDataSuffix = "\n
\n"; $str .= $__debugUtilLabelPrefix . $label . $__debugUtilLabelSuffix; $str .= $__debugUtilDataPrefix; $str .= print_r($d, true); $str .= $__debugUtilDataSuffix; } return $str; } else return ""; } } function _debugAndStop($d, $label="*debug* ") { _debug($d, $label, true); } function _debug($d, $label='*debug* ', $exitHere=false) { DebugOutput::output($d, $label, $exitHere); }