/**
  * checks the piwik environment
  *
  * @return bool
  * @throws Exception
  */
 protected function checkPiwikEnvironment()
 {
     // check if piwik is installed
     if (!\tx_piwikintegration_install::getInstaller()->checkInstallation()) {
         \tx_piwikintegration_install::getInstaller()->installPiwik();
         if (\tx_piwikintegration_install::getInstaller()->checkInstallation()) {
             $this->addFlashMessage('Piwik installed', 'Piwik is now installed / upgraded, wait a moment, reload the page ;) <meta http-equiv="refresh" content="2; URL=mod.php?M=web_txpiwikintegrationM1&uid=' . $this->id . '#reload">', \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
         }
         return FALSE;
     }
     // check whether a page is selected
     if (!$this->id) {
         $this->addFlashMessage('Please select a page in the pagetree', '', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE);
         return FALSE;
     }
     $t = $this->piwikHelper->getPiwikConfigArray($this->id);
     // check whether a configured page is selected
     if (!isset($t['piwik_idsite']) || !$this->piwikHelper->getPiwikSiteIdForPid($this->id)) {
         $this->addFlashMessage('Page is not configured. Did you include the Typoscript template?', '', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE);
         return FALSE;
     }
     // check whether piwik_host is correct
     if ($t['piwik_host'] !== 'typo3conf/piwik/piwik/' && $t['piwik_host'] !== '/typo3conf/piwik/piwik/') {
         $this->addFlashMessage('Piwik host is not set correctly', '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         return FALSE;
     }
     unset($t);
     // check if patch level is correct
     if (!\tx_piwikintegration_install::getInstaller()->checkPiwikPatched()) {
         //prevent lost configuration and so the forced repair.
         $exclude = array('config/config.ini.php');
         \tx_piwikintegration_install::getInstaller()->patchPiwik($exclude);
     }
     return TRUE;
 }