/**
  * Determines the page-data to load.
  * This includes the evaluation of the current page-data and the fallback to another language or even the error-page
  *
  * @throws class_exception
  * @return class_module_pages_page
  */
 private function getPageData()
 {
     $strPagename = $this->getPagename();
     //Load the data of the page
     $objPageData = class_module_pages_page::getPageByName($strPagename);
     //check, if the page is enabled and if the rights are given, or if we want to load a preview of a page
     $bitErrorpage = false;
     if ($objPageData == null || ($objPageData->getIntRecordStatus() != 1 || !$objPageData->rightView())) {
         $bitErrorpage = true;
     }
     //but: if count != 0 && preview && rights:
     if ($bitErrorpage && $objPageData != null && $this->getParam("preview") == "1" && $objPageData->rightEdit()) {
         $bitErrorpage = false;
     }
     //check, if the template could be loaded
     try {
         if (!$bitErrorpage) {
             $this->objTemplate->readTemplate("/module_pages/" . $objPageData->getStrTemplate(), "", false, true);
         }
     } catch (class_exception $objException) {
         $bitErrorpage = true;
     }
     if ($bitErrorpage) {
         //Unfortunately, we have to load the errorpage
         //try to send the correct header
         //page not found
         if ($objPageData == null || $objPageData->getIntRecordStatus() != 1) {
             class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
         }
         //user is not allowed to view the page
         if ($objPageData != null && !$objPageData->rightView()) {
             class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_FORBIDDEN);
         }
         //check, if the page may be loaded using the default-language
         $strPreviousLang = $this->getStrPortalLanguage();
         $objDefaultLang = class_module_languages_language::getDefaultLanguage();
         if ($this->getStrPortalLanguage() != $objDefaultLang->getStrName()) {
             class_logger::getInstance()->addLogRow("Requested page " . $strPagename . " not existing in language " . $this->getStrPortalLanguage() . ", switch to fallback lang", class_logger::$levelWarning);
             $objDefaultLang->setStrPortalLanguage($objDefaultLang->getStrName());
             $objPageData = class_module_pages_page::getPageByName($strPagename);
             $bitErrorpage = false;
             try {
                 if ($objPageData != null) {
                     $this->objTemplate->readTemplate("/module_pages/" . $objPageData->getStrTemplate(), "", false, true);
                 } else {
                     $bitErrorpage = true;
                 }
             } catch (class_exception $objException) {
                 $bitErrorpage = true;
             }
             if ($bitErrorpage) {
                 $strPagename = class_module_system_setting::getConfigValue("_pages_errorpage_");
                 $this->setParam("page", class_module_system_setting::getConfigValue("_pages_errorpage_"));
                 //revert to the old language - fallback didn't work
                 $objDefaultLang->setStrPortalLanguage($strPreviousLang);
             }
         } else {
             $strPagename = class_module_system_setting::getConfigValue("_pages_errorpage_");
             $this->setParam("page", class_module_system_setting::getConfigValue("_pages_errorpage_"));
         }
         $objPageData = class_module_pages_page::getPageByName($strPagename);
         //check, if the page is enabled and if the rights are given, too
         if ($objPageData == null || ($objPageData->getIntRecordStatus() != 1 || !$objPageData->rightView())) {
             //Whoops. Nothing to output here
             throw new class_exception("Requested Page " . $strPagename . " not existing, no errorpage created or set!", class_exception::$level_FATALERROR);
         }
     }
     return $objPageData;
 }