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