TYPO3 CMS  TYPO3_6-2
ReportController.php
Go to the documentation of this file.
1 <?php
3 
21 
27  public function initializeAction() {
28  $vars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('tx_reports_system_reportstxreportsm1');
29  if (!isset($vars['redirect']) && $vars['action'] !== 'index' && !isset($vars['extension']) && is_array($GLOBALS['BE_USER']->uc['reports']['selection'])) {
30  $previousSelection = $GLOBALS['BE_USER']->uc['reports']['selection'];
31  if (!empty($previousSelection['extension']) && !empty($previousSelection['report'])) {
32  $this->redirect('detail', 'Report', NULL, array('extension' => $previousSelection['extension'], 'report' => $previousSelection['report'], 'redirect' => 1));
33  } else {
34  $this->redirect('index');
35  }
36  }
37  }
38 
44  public function indexAction() {
45  $this->view->assignMultiple(array(
46  'reports' => $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'],
47  'menu' => $this->getMenu()
48  ));
49  $this->saveState();
50  }
51 
59  public function detailAction($extension, $report) {
60  $content = ($error = '');
61  $reportClass = NULL;
62  if (
63  isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension])
64  && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension])
65  && isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report])
66  && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report])
67  && isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report]['report'])
68  ) {
69  $reportClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report]['report'];
70  }
71 
72  // If extension has been uninstalled/removed redirect to index
73  if ($reportClass === NULL) {
74  $this->redirect('index');
75  }
76 
77  $reportInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($reportClass, $this);
78  if ($reportInstance instanceof \TYPO3\CMS\Reports\ReportInterface) {
79  $content = $reportInstance->getReport();
80  $this->saveState($extension, $report);
81  } else {
82  $error = $reportClass . ' does not implement the Report Interface which is necessary to be displayed here.';
83  }
84  $this->view->assignMultiple(array(
85  'content' => $content,
86  'error' => $error,
87  'report' => $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report],
88  'menu' => $this->getMenu()
89  ));
90  }
91 
97  protected function getMenu() {
98  $reportsMenuItems = array();
99  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'] as $extKey => $reports) {
100  foreach ($reports as $reportName => $report) {
101  $reportsMenuItems[] = array(
102  'title' => $GLOBALS['LANG']->sL($report['title']),
103  'extension' => $extKey,
104  'report' => $reportName
105  );
106  }
107  }
108  return $reportsMenuItems;
109  }
110 
118  protected function saveState($extension = '', $report = '') {
119  $GLOBALS['BE_USER']->uc['reports']['selection'] = array('extension' => $extension, 'report' => $report);
120  $GLOBALS['BE_USER']->writeUC();
121  }
122 
123 }
redirect($actionName, $controllerName=NULL, $extensionName=NULL, array $arguments=NULL, $pageUid=NULL, $delay=0, $statusCode=303)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]