protected function renderBar($result) { if (strpos($result, '</head>') === false || strpos($result, '</body>') === false) { return $result; } $includes = $this->debugBarRenderer->renderHead(); $this->debugBar->collect(); $toolbar = $this->debugBarRenderer->render(); $result = $this->insertAt($result, strpos($result, '</head>'), $includes); return $this->insertAt($result, strpos($result, '</body>'), $toolbar); }
/** * @param JavascriptRenderer $renderer * @return string */ public function wrapOutput(JavascriptRenderer $renderer) { ob_start(); $renderer->dumpCssAssets(); $css = '<style type="text/css">' . ob_get_contents() . '</style>'; $css .= '<style type="text/css">' . $this->getCustomDebugBarStyle() . '</style>'; ob_clean(); $renderer->dumpJsAssets(); $js = '<script type="text/javascript">' . ob_get_contents() . '</script>'; ob_end_clean(); return $css . $js . $renderer->render(); }
/** * @param UriInterface $uri * * @return ResponseInterface|null */ private function getStaticFile(UriInterface $uri) { $path = $this->extractPath($uri); if (strpos($path, $this->debugBarRenderer->getBaseUrl()) !== 0) { return; } $pathToFile = substr($path, strlen($this->debugBarRenderer->getBaseUrl())); $fullPathToFile = $this->debugBarRenderer->getBasePath() . $pathToFile; if (!file_exists($fullPathToFile)) { return; } $contentType = $this->getContentTypeByFileName($fullPathToFile); $stream = new Stream($fullPathToFile, 'r'); return new Response($stream, 200, ['Content-type' => $contentType]); }
/** * Displays the debug bar * * @return $this */ public function render() { if ($this->enabled()) { echo $this->renderer->render(); } return $this; }
/** * constructor, should be called by all derived views * will cause redirect if $loginrequired and not logged in * @param bool $loginrequired */ public function __construct($loginrequired = false) { if (isset($_COOKIE['PHPSESSID'])) { session_start(); } if ($loginrequired && !Auth::isLoggedIn()) { session_start(); $this->redirect("/login"); } parent::__construct(); $reg = Registry::getInstance(); $this->_context['images'] = $reg->imagePaths; $this->_context['baseHost'] = $reg->baseHost; $this->_context['disqus'] = $reg->disqus; // ownerID, if this is an owned board, this should be filled, for public boards this needs to be false $this->_context['ownerID'] = $reg->ownerID; // ownerType, if this is an owned board, this should be filled, for public boards this doesn't matter $this->_context['ownerType'] = $reg->ownerType; // when user is logged in we provide user object to all pages, false otherwise $this->_context['user'] = Auth::getUser(); // make sure all views have the XSRF Token available $this->_context['XSRF'] = Form::getXSRFToken(); // Global Kingboard information // pass version information $this->_context['Kingboard']['Version'] = Kingboard::VERSION; // ownerName, use Kingboard if not set if (!is_null($reg->ownerName) && $reg->ownerName) { $this->_context['Kingboard']['Name'] = $reg->ownerName; } else { $this->_context['Kingboard']['Name'] = Kingboard::NAME; } // release name $this->_context['Kingboard']['ReleaseName'] = Kingboard::RELEASE_NAME; // pick bootstrap theme path from public/css/themes folder $this->_context['theme'] = !is_null($reg->theme) ? $reg->theme : "default"; // set header image, fall back to default if non configured $this->_context['header_image'] = !is_null($reg->headerImage) ? $reg->headerImage : "/images/banner/kingboard.png"; $debugbar = $reg->debugbar; if (!is_null($debugbar)) { $jsrenderer = new JavascriptRenderer($debugbar, '/DebugBar'); $this->_context['debugbar_header'] = $jsrenderer->renderhead(); $this->_context['debugbar'] = $jsrenderer->render(); } // ingame browser check $this->_context['igb'] = $this->isIGB(); }
/** * @param ServerRequestInterface $request * @param ResponseInterface $response * @param callable $out * * @return ResponseInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out = null) { $outResponse = $out($request, $response); if (!$this->isHtmlAccepted($request)) { return $outResponse; } $debugBarHead = $this->debugBarRenderer->renderHead(); $debugBarBody = $this->debugBarRenderer->render(); if ($this->isHtmlResponse($outResponse)) { $outResponse->getBody()->write($debugBarHead . $debugBarBody); return $outResponse; } $outResponseBody = Serializer::toString($outResponse); $template = '<html><head>%s</head><body><h1>DebugBar</h1><p>Response:</p><pre>%s</pre>%s</body></html>'; $escapedOutResponseBody = htmlspecialchars($outResponseBody); $result = sprintf($template, $debugBarHead, $escapedOutResponseBody, $debugBarBody); return new HtmlResponse($result); }
public function __invoke(ContainerInterface $container = null) { if ($container === null || !$container->has(DebugBar::class)) { $standardDebugBarFactory = new StandardDebugBarFactory(); $debugbar = $standardDebugBarFactory($container); } else { $debugbar = $container->get(DebugBar::class); } $renderer = new JavascriptRenderer($debugbar); $config = $container !== null && $container->has('config') ? $container->get('config') : []; if (isset($config['phpmiddleware']['phpdebugbar']['javascript_renderer'])) { $rendererOptions = $config['phpmiddleware']['phpdebugbar']['javascript_renderer']; } else { $rendererOptions = ['base_url' => '/phpdebugbar']; } $renderer->setOptions($rendererOptions); return $renderer; }
public function getAssetFiles($type = null) { $files = parent::getAssetFiles(null); $files[0][] = 'nucleus/style.css'; $files[1][] = 'nucleus/NucleusDebugBar.js'; foreach ($this->debugBar->getCollectors() as $collector) { if ($collector instanceof IAssetProvider) { $files[0] = array_merge($files[0], $collector->getCssFiles()); $files[1] = array_merge($files[1], $collector->getJsFiles()); } } return $this->filterAssetArray($files, $type); }
/** * {@inheritdoc} */ public function renderHead() { if (!$this->url) { return parent::renderHead(); } $jsModified = $this->getModifiedTime('js'); $cssModified = $this->getModifiedTime('css'); $html = ''; $html .= sprintf('<link rel="stylesheet" type="text/css" href="%s?%s">' . "\n", $this->url->route('debugbar.assets.css'), $cssModified); $html .= sprintf('<script type="text/javascript" src="%s?%s"></script>' . "\n", $this->url->route('debugbar.assets.js'), $jsModified); if ($this->isJqueryNoConflictEnabled()) { $html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n"; } return $html; }
/** * {@inheritdoc} */ public function renderHead() { if (!$this->url) { return parent::renderHead(); } $cssRoute = $this->url->route('debugbar.assets.css', ['v' => $this->getModifiedTime('css')]); $jsRoute = $this->url->route('debugbar.assets.js', ['v' => $this->getModifiedTime('js')]); $html = ''; $html .= "<link rel='stylesheet' type='text/css' href='{$cssRoute}'>"; $html .= "<script type='text/javascript' src='{$jsRoute}'></script>"; if ($this->isJqueryNoConflictEnabled()) { $html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n"; } return $html; }
public function renderHead() { if (!$this->url) { return parent::renderHead(); } // get current application base uri and srote it in a variable // set debugger base uri $jsModified = $this->getModifiedTime('js'); $cssModified = $this->getModifiedTime('css'); $html = ''; $html .= sprintf('<link rel="stylesheet" type="text/css" href="%s?%s">' . "\n", $this->url->get(array('for' => 'debugbar.assets.css')), $cssModified); $html .= sprintf('<script type="text/javascript" src="%s?%s"></script>' . "\n", $this->url->get(array('for' => 'debugbar.assets.js')), $jsModified); if ($this->isJqueryNoConflictEnabled()) { $html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n"; } // reset base uri to its default return $html; }
/** * Injects the js scripts into the given Response. * * @param Response $response A Response instance */ protected function injectScripts(Response $response, JavascriptRenderer $renderer) { if (function_exists('mb_stripos')) { $posrFunction = 'mb_strripos'; $substrFunction = 'mb_substr'; } else { $posrFunction = 'strripos'; $substrFunction = 'substr'; } $content = $response->getContent(); if (false !== ($pos = $posrFunction($content, '</body>'))) { $scripts = $renderer->renderHead() . $renderer->render(); // if ($this->debugbar->getStorage()) { // $scripts .= sprintf('<script > phpdebugbar . setOpenHandler(new PhpDebugBar.OpenHandler({ url: "%s" }));</script // > ', $this->router->generate('_debugbar')); // } $content = $substrFunction($content, 0, $pos) . $scripts . $substrFunction($content, $pos); $response->setContent($content); } }
public function __construct(DebugBar $debugBar, $baseUrl = null, $basePath = null) { parent::__construct($debugBar, $baseUrl, $basePath); $this->cssFiles['laravel'] = __DIR__ . '/Resources/laravel-debugbar.css'; $this->cssVendors['fontawesome'] = __DIR__ . '/Resources/vendor/font-awesome/style.css'; }
/** * * @param JavascriptRenderer $renderer * @return string */ protected function getAssets(JavascriptRenderer $renderer) { ob_start(); echo '<style type="text/css">' . "\n"; $renderer->dumpCssAssets(); // Change icon to CI icon, based on https://github.com/bcit-ci/ci-design/blob/master/website/assets/images/ci-logo.png echo 'div.phpdebugbar-header, a.phpdebugbar-restore-btn, div.phpdebugbar-openhandler .phpdebugbar-openhandler-header {' . 'background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAATCAYAAACZZ43PAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U' . '29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAIRSURBVHjapJQ9TFRBEMdn7zj5iF8JhpwhxkQxxILgRxAKEkNvuAY7C2oTGxpjtLA1hEISKOwMl' . 'HZqLLDRyoSKBo0Up4QQcgXBEAGB2/U3b+cd7+DOxs39d+ftm/nvf2bnnatclOYjJ+erHbKPtdPodfF7kBbXIv8aNwt7csuLTDU/wzFnEFiqBsYNMJ4L0' . 'gPkOBKCuvgQYQ632RtjuwAGmilomACB/c7JC8x2cBic+OSEUOdjKZyMHiJ4GqsTHIBtsCSmrjZCY4I7LhbsLPgD8uB33sl6rl7AURE9EV4tL9eYVXaHB' . 'Rcspt17Kfoo+yHL3foauFotnoILeqLShSBvSGU0IXQyidsa66Dl/hy8SxSoNCpe4uWABSvZL4Jfcvy8PV8Fw3a7yvEMXI81OJRe5I9awWIyIqdRUIRgB' . 'nsC/LB6aEramWe4mfGEAKMXzssZAj3xHHsTkBSIWIDyAaHv7VpVwR5TX9pI3VY4PbkVfAar7JdIb8RKv8XymPVDxvdUqqBiVdfgMrfyBOe32IucVU7bG' . 'zWKWcxN892KNfCyzPozyTtWdhfSV0Tdx15JestFqfxWefxmfbKQKvhK4Gtrqm37HgLe1eP9DbQ+mvIXn5e5WieGyDZJ4D3WtrTPXaZ9Q0ylxLRBmo+C/' . 'Ue4yqWjnoZ1OFeVNsyP2X43gh44rrD1SWuGr3SVERpCkP8ZfwUYAL2WpEUbzbyiAAAAAElFTkSuQmCC") no-repeat scroll 5px 4px #efefef;' . '}' . '.phpdebugbar-widgets-value.phpdebugbar-widgets-warning { color: #f39c12; }'; echo '</style>' . "\n"; echo '<script type="text/javascript">' . "\n"; $renderer->dumpJsAssets(); echo '</script>' . "\n"; return str_replace(['PhpDebugbarFontAwesome', 'phpdebugbar-fa'], ['FontAwesome', 'fa'], ob_get_clean()); }
public function renderBody(IEvent $event) { $content = $event->getStr("content"); $content .= $this->_debugRender->render(); return $content; }
/** * @return string */ public function renderHead() { return $this->renderer->renderHead(); }