/**
  * Read template file set in flexform or TypoScript, read the file's contents to $this->templateFile
  *
  * @param $settings The formhandler settings
  * @return void
  * @author	Reinhard Führicht <*****@*****.**>
  */
 public static function readTemplateFile($templateFile, &$settings)
 {
     $templateCode = FALSE;
     //template file was not set in flexform, search TypoScript for setting
     if (!$templateFile) {
         if (!$settings['templateFile'] && !!$settings['templateFile.']) {
             return '';
         }
         $templateFile = $settings['templateFile'];
         if (isset($settings['templateFile.']) && is_array($settings['templateFile.'])) {
             $templateFile = Tx_Formhandler_StaticFuncs::getSingle($settings, 'templateFile');
             if (strpos($templateFile, "\n") === FALSE) {
                 $templateFile = Tx_Formhandler_StaticFuncs::resolvePath($templateFile);
                 if (!@file_exists($templateFile)) {
                     Tx_Formhandler_StaticFuncs::throwException('template_file_not_found', $templateFile);
                 }
                 $templateCode = t3lib_div::getURL($templateFile);
             }
         } else {
             $templateFile = Tx_Formhandler_StaticFuncs::resolvePath($templateFile);
             if (!@file_exists($templateFile)) {
                 Tx_Formhandler_StaticFuncs::throwException('template_file_not_found', $templateFile);
             }
             $templateCode = t3lib_div::getURL($templateFile);
         }
     } else {
         if (strpos($templateFile, "\n") === FALSE) {
             $templateFile = Tx_Formhandler_StaticFuncs::resolvePath($templateFile);
             if (!@file_exists($templateFile)) {
                 Tx_Formhandler_StaticFuncs::throwException('template_file_not_found', $templateFile);
             }
             $templateCode = t3lib_div::getURL($templateFile);
         } else {
             // given variable $templateFile already contains the template code
             $templateCode = $templateFile;
         }
     }
     if (strlen($templateCode) === 0) {
         Tx_Formhandler_StaticFuncs::throwException('empty_template_file', $templateFile);
     }
     if (stristr($templateCode, '###TEMPLATE_') === FALSE) {
         Tx_Formhandler_StaticFuncs::throwException('invalid_template_file', $templateFile);
     }
     return $templateCode;
 }