/** * @param ServerRequestInterface $request * @param ResponseInterface $response * @param callable $next * * @return ResponseInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { if ($staticFile = $this->getStaticFile($request->getUri())) { return $staticFile; } $outResponse = $next($request, $response); if (!$this->isHtmlAccepted($request)) { return $outResponse; } $debugBarHead = $this->debugBarRenderer->renderHead(); $debugBarBody = $this->debugBarRenderer->render(); if ($this->isHtmlResponse($outResponse)) { $body = $outResponse->getBody(); if (!$body->eof() && $body->isSeekable()) { $body->seek(0, SEEK_END); } $body->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 renderHead(IEvent $event) { $content = $event->getStr("content"); $content .= $this->_debugRender->renderHead(); $content .= '<style>' . 'dl.phpdebugbar-widgets-kvlist dt { width:300px; }' . '</style>'; return $content; }
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 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); }
/** * {@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); } }
/** * @return string */ public function renderHead() { return $this->renderer->renderHead(); }