ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPlainTextHandler.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
14require_once("./Services/Exceptions/lib/Whoops/Handler/HandlerInterface.php");
15require_once("./Services/Exceptions/lib/Whoops/Handler/Handler.php");
16
19
21 const KEY_SPACE = 25;
22
28 public function handle() {
29 echo "<pre>\n";
30 echo $this->content();
31 echo "</pre>\n";
32 }
33
39 protected function content() {
40 return $this->pageHeader()
41 .$this->exceptionContent()
42 .$this->tablesContent()
43 ;
44 }
45
51 protected function pageHeader() {
52 return "";
53 }
54
60 protected function exceptionContent() {
61 return Formatter::formatExceptionPlain($this->getInspector());
62 }
63
69 protected function tablesContent() {
70 $ret = "";
71 foreach ($this->tables() as $title => $content) {
72 $ret .= "\n\n-- $title --\n\n";
73 if (count($content) > 0) {
74 foreach ($content as $key => $value) {
75 $key = str_pad($key, self::KEY_SPACE);
76
77 // indent multiline values, first print_r, split in lines,
78 // indent all but first line, then implode again.
79 $first = true;
80 $indentation = str_pad("", self::KEY_SPACE);
81 $value = implode("\n", array_map(function($line) use (&$first, $indentation) {
82 if ($first) {
83 $first = false;
84 return $line;
85 }
86 return $indentation.$line;
87 }, explode("\n", print_r($value, true))));
88
89 $ret .= "$key: $value\n";
90 }
91 }
92 else {
93 $ret .= "empty\n";
94 }
95 }
96 return $ret;
97 }
98
104 protected function tables() {
105 return array
106 ( "GET Data" => $_GET
107 , "POST Data" => $_POST
108 , "Files" => $_FILES
109 , "Cookies" => $_COOKIES
110 , "Session" => isset($_SESSION) ? $_SESSION : array()
111 , "Server/Request Data" => $_SERVER
112 , "Environment Variables" => $_ENV
113 );
114 }
115}
116
117?>
$_GET["client_id"]
$_SESSION["AccountId"]
Abstract implementation of a Handler.
Definition: Handler.php:17
pageHeader()
Get the header for the page.
tablesContent()
Get the header for the page.
exceptionContent()
Get a short info about the exception.
handle()
Last missing method from HandlerInterface.
tables()
Get the tables that should be rendered.
content()
Assemble the output for this handler.
$_POST['username']
Definition: cron.php:12
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']