1<?php 2 3namespace Icinga\Module\Reporting\Controllers; 4 5use GuzzleHttp\Psr7\ServerRequest; 6use Icinga\Module\Reporting\Hook\ReportHook; 7use Icinga\Module\Reporting\Web\Forms\ReportForm; 8use Icinga\Module\Reporting\Web\Controller; 9use Icinga\Web\Hook; 10use Icinga\Web\Url; 11use ipl\Html\Html; 12 13class PlugController extends Controller 14{ 15 public function indexAction() 16 { 17 $moduleToShow = strtolower($this->params->get('module', 'reporting')); 18 19 $reportsByModule = []; 20 21 foreach (ReportHook::getReports() as $class => $report) { 22 $moduleName = $report->getModuleName(); 23 24 if (! isset($reportsByModule[$moduleName])) { 25 $reportsByModule[$moduleName] = []; 26 } 27 28 $reportsByModule[$moduleName][$class] = $report; 29 } 30 31 $editor = Html::tag('div', ['class' => 'editor']); 32 33 $nav = []; 34 35 $cards = []; 36 37 foreach ($reportsByModule as $moduleName => $reports) { 38 $link = Html::tag('a', ['href' => Url::fromRequest(['module' => $moduleName])], $moduleName); 39 40 $nav[] = $link; 41 42 if ($moduleName !== $moduleToShow) { 43 continue; 44 } 45 46 $link->getAttributes()->add('class', 'active'); 47 48 foreach ($reports as $report) { 49 $cards[] = Html::tag( 50 'div', 51 ['class' => 'card'], 52 [ 53 Html::tag('div', ['class' => 'card-top'], $report->getPreview()), 54 Html::tag( 55 'div', 56 ['class' => 'card-content'], 57 Html::tag('h5', ['class' => 'card-title'], $report->getName()), 58 Html::tag('p', ['class' => 'card-text'], $report->getDescription()) 59 ) 60 ] 61 ); 62 } 63 } 64 65 $editor->add(Html::tag('div', ['class' => 'editor-nav'], $nav)); 66 $editor->add(Html::tag('div', ['class' => 'editor-content'], $cards)); 67 68 $this->addContent($editor); 69 70 $this->addContent(Html::tag('a', ['href' => 'plug', 'class' => 'modal-toggle', 'data-base-target' => 'modal-container'], 'Modal')); 71 } 72} 73