public function main() { $out = ''; $conf = $this->getModule()->getConfigurations(); $file = tx_rnbase_util_Files::getFileAbsFileName($conf->get($this->getConfId() . 'template')); $templateCode = tx_rnbase_util_Network::getURL($file); if (!$templateCode) { return $conf->getLL('msg_template_not_found') . '<br />File: \'' . $file . '\'<br />ConfId: \'' . $this->getConfId() . 'template\''; } $subpart = '###' . strtoupper($this->getFuncId()) . '###'; $template = tx_rnbase_util_Templates::getSubpart($templateCode, $subpart); if (!$template) { return $conf->getLL('msg_subpart_not_found') . ': ' . $subpart; } $start = microtime(TRUE); $memStart = memory_get_usage(); $out .= $this->getContent($template, $conf, $conf->getFormatter(), $this->getModule()->getFormTool()); if (tx_rnbase_util_BaseMarker::containsMarker($out, 'MOD_')) { $markerArr = array(); $memEnd = memory_get_usage(); $markerArr['###MOD_PARSETIME###'] = microtime(TRUE) - $start; $markerArr['###MOD_MEMUSED###'] = $memEnd - $memStart; $markerArr['###MOD_MEMSTART###'] = $memStart; $markerArr['###MOD_MEMEND###'] = $memEnd; $out = tx_rnbase_util_Templates::substituteMarkerArrayCached($out, $markerArr); } return $out; }
/** * Render the PHP template, translate and return the output as string * * The ".php" suffix is added in this function. * Call this function after the $pathToTemplates is set. * The return value is the rendered result of the template, followed by translation. * It is typically a (x)html string, but can be used for any other text based format. * * @param string name of template file without the ".php" suffix * @param tx_rnbase_configurations configuration instance * @return string typically an (x)html string */ function render($view, $configurations) { $link = $configurations->createLink(); // Die ViewData bereitstellen $viewData =& $configurations->getViewData(); $formatter = tx_rnbase::makeInstance('tx_rnbase_util_FormatUtil', $configurations); $path = $this->getTemplate($view); // Für den PHP Include benötigen wir den absoluten Pfad $path = tx_rnbase_util_Files::getFileAbsFileName($path); ob_start(); include $path; $out = ob_get_clean(); return $out; }
/** * Load a local lang from a file. * merging with the existing local lang * * @param string $filename * * @return void */ public function loadLLFile($filename) { if (!$filename) { return; } // Find language file $basePath = tx_rnbase_util_Files::getFileAbsFileName($filename); // php or xml as source: In any case the charset will be that of the system language. // However, this function guarantees only return output for default language plus the specified language (which is different from how 3.7.0 dealt with it) $utility = tx_rnbase_util_Typo3Classes::getGeneralUtilityClass(); self::addLang($utility::readLLfile($basePath, self::getLLKey(), $GLOBALS['TSFE']->renderCharset)); if ($llKey = self::getLLKey(TRUE)) { self::addLang($utility::readLLfile($basePath, $llKey, $GLOBALS['TSFE']->renderCharset)); } }
/** * Returns the file for module HTML template. This can be overwritten. * The first place to search for template is EXT:[your_ext_key]/mod1/template.html. If this file * not exists the default from rn_base is used. Overwrite this method to set your own location. * @return string */ protected function getModuleTemplate() { $filename = $this->getConfigurations()->get('template'); if (file_exists(tx_rnbase_util_Files::getFileAbsFileName($filename, TRUE, TRUE))) { return $filename; } $filename = 'EXT:' . $this->getExtensionKey() . '/mod1/template.html'; if (file_exists(tx_rnbase_util_Files::getFileAbsFileName($filename, TRUE, TRUE))) { return $filename; } return 'EXT:rn_base/mod/template.html'; }
/** * Returns the template to use. * If TemplateFile is set, it is preferred. Otherwise * the filename is build from pathToTemplates, the templateName and $extension. * * @param string name of template * @param string file extension to use * @return complete filename of template */ function getTemplate($templateName, $extension = '.php', $forceAbsPath = 0) { if (strlen($this->_pathToFile) > 0) { return $forceAbsPath ? tx_rnbase_util_Files::getFileAbsFileName($this->_pathToFile) : $this->_pathToFile; } $path = $this->pathToTemplates; $path .= substr($path, -1, 1) == '/' ? $templateName : '/' . $templateName; $extLen = strlen($extension); $path .= substr($path, $extLen * -1, $extLen) == $extension ? '' : $extension; return $path; }