function dispatch() { $tpl = $this->template->create('404'); $response = new k_HtmlResponse($tpl->render($this)); $response->setStatus(404); return $response; }
function renderHtml() { $this->document->setTitle('Login'); $response = new k_HtmlResponse("<form method='post' action='" . htmlspecialchars($this->url()) . "'>\n <p>\n <label>\n Brugernavn\n <input type='text' name='username' />\n </label>\n </p>\n <p>\n <label>\n Adgangskode\n <input type='password' name='password' />\n </label>\n </p>\n <p>\n <input type='submit' value='Login' />\n </p>\n</form>\n"); $response->setStatus(401); return $response; }
function test_404_response_should_output_custom_content_if_any() { $output = new k_adapter_DummyOutputAccess(); $response = new k_HtmlResponse("I didn't find it"); $response->setStatus(404); $response->out($output); $this->assertEqual(404, $output->http_response_code); $this->assertEqual("I didn't find it", $output->body); }
function decorate(k_Response $response) { if ($response->status() >= 300 && $response->status() < 400) { return new k_HtmlResponse($this->render($response, true)); } if ($response instanceof k_HtmlResponse) { $html = $response->toContentType('text/html'); if (strpos($html, '</body>') === false) { $body = $html . $this->render($response, false); } else { $body = str_replace('</body>', $this->render($response, false) . '</body>', $html); } $out = new k_HtmlResponse($body); $out->setStatus($response->status()); $out->setCharset($response->charset()); foreach ($response->headers() as $key => $value) { $out->setHeader($key, $value); } return $out; } return $response; }
function renderHtml() { $response = new k_HtmlResponse("<html><head><title>Authentication required</title></head><body><form method='post' action='" . htmlspecialchars($this->url()) . "'>\n <h1>Authentication required</h1>\n <p>\n <label>\n username:\n <input type='text' name='username' />\n </label>\n </p>\n <p>\n <label>\n password:\n <input type='password' name='password' />\n </label>\n </p>\n <p>\n <input type='submit' value='Login' />\n </p>\n</form></body></html>"); $response->setStatus(401); return $response; }
function renderHtml() { $response = new k_HtmlResponse("<html><head><title>Authentication required</title></head><body><form method='post' action='" . htmlspecialchars($this->url()) . "'>\n <h1>Authentication required</h1>\n <h2>OpenID Login</h2>\n <p>\n" . implode("<br/>", $this->errors) . "\n </p>\n <p>\n <label>\n open-id url:\n <input type='text' name='openid_identifier' value='' />\n </label>\n </p>\n <p>\n <input type='submit' value='Login' />\n </p>\n</form></body></html>"); $response->setStatus(401); return $response; }
protected function dispatchRoot($root_class_name) { try { $class_name = $root_class_name; while (true) { try { $root = $this->components()->create($class_name, $this->context()); $response = $root->dispatch(); if (!$response instanceof k_Response) { $response = new k_HtmlResponse($response); } $response->setCharset($this->charsetStrategy()->responseCharset()); return $response; } catch (k_MetaResponse $ex) { $class_name = $ex->componentName(); } } } catch (k_Response $ex) { return $ex; } }
function test_html_response_can_be_constructed_from_a_text_response() { $t1 = new k_TextResponse("Foo & Bar"); $h = new k_HtmlResponse($t1); $this->assertEqual($h->toContentType('text/html'), "Foo & Bar"); }