Makes the debug pretty for output
also adds the option to place a title :)

@param integer|string|array|bool|object $var
@param string $title
@param bool $return
@return bool
11878
public static function dump($var, $title = false, $return = false) {
        // capture on return
        if($return)
            ob_start();

        // start pre, got title?
        echo '<pre style="'. implode(';', self::$pre) .'">';
        if($title)
            echo '<span style="'. implode(';', self::$title) .'">'. $title .'</span>';

        // do the deed and end pre
        var_dump($var);
        echo "</pre>";

        // return output
        return $return ? ob_get_clean() : true;
    }
1164599
public static function json($var, $continue = false, $hide = false, $return = false){
        $Stop = new \Stop\Dumper\Json($hide, $continue, $return, Dumper\AbstractDumper::FORMAT_JSON);
        $Stop->var_dump($var);
    }
1039256
public static function debug($variable)
    {
        ob_start();
        var_dump($variable);
        $output = ob_get_clean();
        $maps = ['string' => "/(string\((?P<length>\d+)\)) (?P<value>\"(?<!\\\).*\")/i", 'array' => "/\[\"(?P<key>.+)\"(?:\:\"(?P<class>[a-z0-9_\\\]+)\")?(?:\:(?P<scope>public|protected|private))?\]=>/Ui", 'countable' => "/(?P<type>array|int|string)\((?P<count>\d+)\)/", 'resource' => "/resource\((?P<count>\d+)\) of type \((?P<class>[a-z0-9_\\\]+)\)/", 'bool' => "/bool\((?P<value>true|false)\)/", 'float' => "/float\((?P<value>[0-9\.]+)\)/", 'object' => "/object\((?P<class>\S+)\)\#(?P<id>\d+) \((?P<count>\d+)\)/i"];
        foreach ($maps as $function => $pattern) {
            $output = preg_replace_callback($pattern, function ($matches) use ($function) {
                switch ($function) {
                    case 'string':
                        $matches['value'] = htmlspecialchars($matches['value']);

                        return '<span style="color: #0000FF;">string</span>(<span style="color: #1287DB;">'.$matches['length'].')</span> <span style="color: #6B6E6E;">'.$matches['value'].'</span>';

                    case 'array':
                        $key = '<span style="color: #008000;">"'.$matches['key'].'"</span>';
                        $class = '';
                        $scope = '';
                        if (isset($matches['class']) && !empty($matches['class'])) {
                            $class = ':<span style="color: #4D5D94;">"'.$matches['class'].'"</span>';
                        }
                        if (isset($matches['scope']) && !empty($matches['scope'])) {
                            $scope = ':<span style="color: #666666;">'.$matches['scope'].'</span>';
                        }

                        return '['.$key.$class.$scope.']=>';

                    case 'countable':
                        $type = '<span style="color: #0000FF;">'.$matches['type'].'</span>';
                        $count = '(<span style="color: #1287DB;">'.$matches['count'].'</span>)';

                        return $type.$count;

                    case 'bool':
                        return '<span style="color: #0000FF;">bool</span>(<span style="color: #0000FF;">'.$matches['value'].'</span>)';

                    case 'float':
                        return '<span style="color: #0000FF;">float</span>(<span style="color: #1287DB;">'.$matches['value'].'</span>)';

                    case 'resource':
                        return '<span style="color: #0000FF;">resource</span>(<span style="color: #1287DB;">'.$matches['count'].'</span>) of type (<span style="color: #4D5D94;">'.$matches['class'].'</span>)';

                    case 'object':
                        return '<span style="color: #0000FF;">object</span>(<span style="color: #4D5D94;">'.$matches['class'].'</span>)#'.$matches['id'].' (<span style="color: #1287DB;">'.$matches['count'].'</span>)';

                }
            }, $output);
        }
        $header = '';
        list($debugfile) = debug_backtrace();

        if (!empty($debugfile['file'])) {
            $header = '<h4 style="border-bottom:1px solid #bbb;font-weight:bold;margin:0 0 10px 0;padding:3px 0 10px 0">'.$debugfile['file'].'</h4>';
        }

        echo '<pre style="background-color: #CDDCF4;border: 1px solid #bbb;border-radius: 4px;-moz-border-radius:4px;-webkit-border-radius\:4px;font-size:12px;line-height:1.4em;margin:30px;padding:7px">'.$header.$output.'</pre>';
    }
814527
public function dump($return = false){
		$sql = PHP_SAPI === 'cli'
			? preg_replace('/\s+/', ' ', $this->parse()) . "\n"
			: Manager::highlightSql($this->parse());
		if(!$return)
			echo $sql;
		return $return ? $sql : $this;
	}
40374
public function postActionAllButton($title, $url, array $options = array())
    {
        $default_options = ['class'        => 'btn btn-default btn-xs action_all_btn',
                            'disabled'     => 'disabled',
                            'unlockFields' => ['checked_ids'],
                            'data-confirm' => null
                           ];

        if(isset($options['confirm'])){
            $options['data-confirm'] = $options['confirm'];
            unset($options['confirm']);
        }

        $options = array_merge($default_options, $options);

        $html = $this->postButton($title, $url, $options);

        return $html;
    }
1072765
public function finalize($return = false) {
		$script = $this->_arrayToObject('matching', $this->matching, false, true) . PHP_EOL;
		$script .= $this->_arrayToObject('gIcons' . static::$mapCount, $this->icons, false, false) . '

	jQuery(document).ready(function() {
		';

		$script .= $this->map;
		if ($this->_runtimeConfig['geolocate']) {
			$script .= $this->_geolocate();
		}

		if ($this->_runtimeConfig['showMarker'] && !empty($this->markers) && is_array($this->markers)) {
			$script .= implode($this->markers, ' ');
		}

		if ($this->_runtimeConfig['autoCenter']) {
			$script .= $this->_autoCenter();
		}
		$script .= '

	});';
		static::$mapCount++;
		if ($return) {
			return $script;
		}
		$this->Html->scriptBlock($script, ['block' => true]);
	}
954662
public static function dump($var, $echo = true, $label = null, $strict = true)
    {
        $label = ($label === null) ? '' : rtrim($label) . ' ';
        if (!$strict) {
            if (ini_get('html_errors')) {
                $output = print_r($var, true);
                $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
            } else {
                $output = $label . print_r($var, true);
            }
        } else {
            ob_start();
            var_dump($var);
            $output = ob_get_clean();
            if (!extension_loaded('xdebug')) {
                $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
                $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
            }
        }
        if ($echo) {
            echo($output);
            
            return null;
        } else {
            return $output;
        }
    }
471839
public function debugVariable($val, $caller, $showHeader = true)
    {
        $text = $this->debugVariableText($val);
        if ($showHeader) {
            $callerFormatted = $this->formatCaller($caller);
            return "Debug ($callerFormatted)\n{$text}\n\n";
        } else {
            return $text;
        }
    }
325709
public static function vd($var, bool $dump = true, bool $stop = true, int $obLevel = 0): void
    {
        if ($stop) {
            while (ob_get_level() > $obLevel) {
                ob_end_clean();
            }
        }
        
        ob_start();
        if (empty($_SERVER['DOCUMENT_ROOT'])) {
            $dump ? var_dump($var) : print_r($var);
            echo PHP_EOL . str_replace("=>\n", '  =>', ob_get_clean());
        } else {
            echo '<pre>';
            $dump ? var_dump($var) : print_r($var);
            echo htmlspecialchars(str_replace("=>\n", '  =>', ob_get_clean()));
            echo '</pre>';
        }
        
        if ($stop) {
            throw new DebugStopExecutionException();
        }
    }
537860
public static function dump( $var, $format = null ) {

		if( !static::isDebug() )
			return;

		$dumpers = [
			static::DUMP_HTML     => '\\yolk\\debug\\HTMLDumper',
			static::DUMP_TERMINAL => '\\yolk\\debug\\TerminalDumper',
			static::DUMP_TEXT     => '\\yolk\\debug\\TextDumper',
		];

		// auto-detect format if unknown or none specified
		if( !isset($dumpers[$format]) )
			$format = static::isCLI() ? static::DUMP_TERMINAL : static::DUMP_HTML;

		$dumpers[$format]::dump($var);

	}
392556
public function output($view = null, $return = false) {
        if ($view instanceof View) {
            $this->view = $view;
        } else if (is_string($view) || is_bool($view) || is_numeric($view)) {
            $this->view = new SimpleView ($view);
        } else if (is_array($view)) {
            $this->view = new JsonView ($view);
        } else if (is_object($view)) {
            $this->view = new JsonView (get_object_vars($view));
        }

        if ($this->view instanceof View) {
            if ($return) {
                $content = $this->view->render();

                return $content;
            } else {
                $this->view->echoHeader();
                $content = $this->view->render();
                if (is_string($content) && $content) {
                    $content = apply_filter('before_output_content', $content, $this->view);
                    echo $content;
                }
            }
        } else if (!$return) {
            Response::respond(404);
        }

        return null;
    }
292532
protected function printDebug($key = '', $value = null, $return = false)
    {
        if ($this->debug !== true) {
            return false;
        }

        if (!is_string($value)) {
            $value = print_r($value, true);
        }

        $line = sprintf('[DEBUG] %s: %s', $key, $value);

        if ($return === false) {
            return print_r($line . PHP_EOL);
        }

        return $line;
    }
972289
public function asciiMultiLine($var, $noCarriageReturn = false) : string
    {
        // Remove lower ASCII except newline \x0A and CR \x0D,
        // and remove DEL and upper range.
        $s = preg_replace(
            !$noCarriageReturn ? '/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/' : '/[\x00-\x09\x0B-\x1F\x7F]/',
            '',
            filter_var('' . $var, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_HIGH)
        );
        // preg_replace() emits old-school warning on error; we want exception.
        if (!$s && $s === null) {
            throw new \RuntimeException('PHP native regex function failed.');
        }
        return $s;
    }
399022
public static function export($class, $name, $return = false)
    {
        $refl = new self($class, $name);
        $value = $refl->getValue();

        $str = \sprintf('Constant [ public %s %s ] { %s }', \gettype($value), $refl->getName(), $value);

        if ($return) {
            return $str;
        }

        echo $str . "\n";
    }
284411
public function displayPaging($script = false, $return = false, $additionalVars = array())
    {
        $summary = $this->getSummary();
        $paginator = $this->getPagination($script, $additionalVars);
        if ($summary->pages > 1) {
            $html = '<div class="ccm-spacer"></div>';
            $html .= '<div class="ccm-pagination">';
            $html .= '<span class="ccm-page-left">' . $paginator->getPrevious() . '</span>';
            $html .= $paginator->getPages();
            $html .= '<span class="ccm-page-right">' . $paginator->getNext() . '</span>';
            $html .= '</div>';
        }
        if (isset($html)) {
            if ($return) {
                return $html;
            } else {
                echo $html;
            }
        }
    }
713264
public static function phpArray($var, $varname = 'varName', $isReturn = false)
    {
        if (!self::isDebug()) {
            return false;
        }

        $output = JBDump_array2php::toString($var, $varname);
        if ($isReturn) {
            return $output;
        }

        $_this = self::i();
        $_this->_dumpRenderHtml($output, $varname, $params);

        return $_this;
    }
631314
public function render( $return = false ) {

		// Get the rendered output.
		$output = $this->get_renderer()->render( $this, true );

		if ( $return ) {
			return $output;
		}

		echo wp_kses( $output, wp_kses_allowed_html( 'post' ) );
	}