4
4
5
5
namespace Icinga \Module \Reporting \Reports ;
6
6
7
+ use Icinga \Application \Icinga ;
7
8
use Icinga \Module \Reporting \Hook \ReportHook ;
8
9
use Icinga \Module \Reporting \Timerange ;
9
10
use ipl \Html \HtmlString ;
@@ -21,20 +22,26 @@ public function getHtml(Timerange $timerange, array $config = null)
21
22
phpinfo ();
22
23
$ html = ob_get_clean ();
23
24
24
- $ doc = new \DOMDocument ();
25
- @$ doc ->loadHTML ($ html );
25
+ if (! Icinga::app ()->isCli ()) {
26
+ $ doc = new \DOMDocument ();
27
+ @$ doc ->loadHTML ($ html );
26
28
27
- $ style = $ doc ->getElementsByTagName ('style ' )->item (0 );
28
- $ style ->parentNode ->removeChild ($ style );
29
+ $ style = $ doc ->getElementsByTagName ('style ' )->item (0 );
30
+ $ style ->parentNode ->removeChild ($ style );
29
31
30
- $ title = $ doc ->getElementsByTagName ('title ' )->item (0 );
31
- $ title ->parentNode ->removeChild ($ title );
32
+ $ title = $ doc ->getElementsByTagName ('title ' )->item (0 );
33
+ $ title ->parentNode ->removeChild ($ title );
32
34
33
- $ meta = $ doc ->getElementsByTagName ('meta ' )->item (0 );
34
- $ meta ->parentNode ->removeChild ($ meta );
35
+ $ meta = $ doc ->getElementsByTagName ('meta ' )->item (0 );
36
+ $ meta ->parentNode ->removeChild ($ meta );
35
37
36
- $ doc ->getElementsByTagName ('div ' )->item (0 )->setAttribute ('class ' , 'system-report ' );
38
+ $ doc ->getElementsByTagName ('div ' )->item (0 )->setAttribute ('class ' , 'system-report ' );
37
39
38
- return new HtmlString ($ doc ->saveHTML ());
40
+ $ html = $ doc ->saveHTML ();
41
+ } else {
42
+ $ html = nl2br ($ html );
43
+ }
44
+
45
+ return new HtmlString ($ html );
39
46
}
40
47
}
0 commit comments